package com.se.http;

import lombok.ToString;

import java.util.Map;

/**
 * @author hdu_huang
 * @since 2021/7/27 22:02.
 */
@ToString
public class HttpResult {
    public final int code;
    public final String content;
    public final Map<String, String> respHeaders;

    public HttpResult(int code, String content, Map<String, String> respHeaders) {
        this.code = code;
        this.content = content;
        this.respHeaders = respHeaders;
    }

    public String getHeader(String name) {
        return respHeaders.get(name);
    }

    public String getContentType() {
        return getHeader("Content-Type");
    }

    public boolean isSuccess() {
        return code >= 200 && code < 300;
    }
}
